home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / mupad / mu1 / pkgtool < prev    next >
Encoding:
Text File  |  1996-11-16  |  25.7 KB  |  786 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1993, 1994 Patrick Volkerding, Moorhead, Minnesota USA
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is 
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. #    notice, this list of conditions and the following disclaimer.
  11. #
  12. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  14. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  15. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  16. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  19. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  20. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  21. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. #
  23.  
  24. # Wed, 27 Apr 1994 00:06:50 -0700 (PDT)
  25. # Optimization by David Hinds.
  26.  
  27. SOURCE_DIR=/var/adm/mount
  28. umask 000
  29. ASK="tagfiles"
  30. if [ ! -d /usr/sbin ]; then # we must be on the bootdisk
  31.  TARGET_DIR=/mnt
  32.  TMP=/mnt/tmp
  33.  if mount | fgrep "on /mnt" 1> /dev/null 2>&1 ; then # good
  34.   echo > /dev/null
  35.  else # bad
  36.   echo
  37.   echo
  38.   echo "You can't run pkgtool from the rootdisk until you've mounted your Linux"
  39.   echo "partitions beneath /mnt. Here are some examples of this:"
  40.   echo
  41.   echo "If your root partition is /dev/hda1, and is using ext2fs, you would type:"
  42.   echo "mount /dev/hda1 /mnt -t ext2"
  43.   echo
  44.   echo "Then, supposing your /usr partition is /dev/hda2, you must do this:"
  45.   echo "mount /dev/hda2 /mnt/usr -t ext2"
  46.   echo
  47.   echo "Please mount your Linux partitions and then run pkgtool again."
  48.   echo
  49.   exit
  50.  fi
  51.  if [ ! -d $TMP ]; then
  52.   mkdir -p $TMP
  53.   chmod 1777 $TMP
  54.  fi
  55. else
  56.  TARGET_DIR=/
  57.  TMP=/tmp
  58. fi
  59. ADM_DIR=$TARGET_DIR/var/adm
  60. LOG=$TMP/PKGTOOL.REMOVED
  61.  
  62. keep_files() {
  63.  while read FILE ; do
  64.   if [ -f "$TARGET_DIR/$FILE" ]; then
  65.     echo "  --> $FILE was found in another package. Skipping." >> $LOG
  66.   fi
  67.  done
  68.  }
  69.  
  70. keep_links() {
  71.  while read LINK ; do
  72.   echo "Duplicate link. Not executing: $LINK" >> $LOG
  73.  done
  74. }
  75.  
  76. delete_files() {
  77.  while read FILE ; do
  78.   if [ -f "$TARGET_DIR/$FILE" ]; then
  79.     echo "  --> Deleting $FILE" >> $LOG
  80.     rm -f $TARGET_DIR/$FILE
  81.   fi
  82.  done
  83.  }
  84.  
  85. delete_links() {
  86.  while read LINK ; do
  87.   echo "Unique link. Executing: $LINK" >> $LOG
  88.  done
  89. }
  90.  
  91. # Conversion to 'comm' utility by Mark Wisdom.
  92. remove_packages() {
  93.  for package_name in $* 
  94.  do
  95.   if [ -r $ADM_DIR/packages/$package_name ]; then
  96.    dialog --title "PACKAGE REMOVAL IN PROGRESS" --infobox "Removing \
  97. package $package_name. Since each file must be checked \
  98. against the contents of every other installed package to avoid wiping out \
  99. areas of overlap, this process can take quite some time. If you'd like to \
  100. watch the progress, flip over to another virtual console and type 'tail -f \
  101. /tmp/PKGTOOL.REMOVED'." 9 60
  102.    echo "Removing package $package_name:" >> $LOG
  103.    if fgrep "./" $ADM_DIR/packages/$package_name 1> /dev/null 2>&1; then
  104.     TRIGGER=".\/"
  105.    else
  106.     TRIGGER="FILE LIST:"
  107.    fi
  108.    echo "Removing files:" >> $LOG
  109.    sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$package_name | sort -u > $TMP/delete_list
  110.    # Pat's new-new && improved pre-removal routine.
  111.    for DIR in $ADM_DIR/removed_packages $ADM_DIR/removed_scripts ; do
  112.     if [ ! -d $DIR ] ; then mkdir -p $DIR ; chmod 755 $DIR ; fi
  113.    done
  114.    mv $ADM_DIR/packages/$package_name $ADM_DIR/removed_packages 1> /dev/null 2>&1
  115.    # Look for duplicated links and leave them in place.
  116.    if [ -r $ADM_DIR/scripts/$package_name ]; then
  117.     cat $ADM_DIR/scripts/$package_name | fgrep 'rm -rf' | sort -u > $TMP/del_link_list
  118.     mv $ADM_DIR/scripts/$package_name $ADM_DIR/removed_scripts 1> /dev/null 2>&1
  119.     cat $ADM_DIR/scripts/* | fgrep 'rm -rf' | sort -u > $TMP/required_links
  120.     comm -12 $TMP/del_link_list $TMP/required_links | keep_links
  121.     comm -23 $TMP/del_link_list $TMP/required_links | delete_links
  122.     comm -23 $TMP/del_link_list $TMP/required_links > $TMP/delscript
  123.     ( cd $TARGET_DIR ; sh $TMP/delscript )
  124.     rm -f $TMP/del_link_list $TMP/required_links $TMP/delscript
  125.    fi
  126.    cat $ADM_DIR/packages/* | sort -u > $TMP/required_files
  127.    comm -12 $TMP/delete_list $TMP/required_files | keep_files
  128.    comm -23 $TMP/delete_list $TMP/required_files | delete_files
  129.    rm -f $TMP/delete_list
  130.    rm -f $TMP/required_files
  131.   else
  132.    echo "No such package: $package_name. Can't remove." >> $LOG
  133.   fi
  134.  done
  135. }
  136.  
  137. # Here, we read the list of arguments passed to the pkgtool script.
  138. if [ $# -gt 0 ]; then # there are arguments to the command
  139.  while [ $# -gt 0 ]; do
  140.   case "$1" in
  141.   "-sets")
  142.    DISK_SETS=`echo $2 | tr "[A-Z]" "[a-z]"` ; shift 2 ;;
  143.   "-source_mounted")
  144.    SOURCE_MOUNTED="always" ; shift 1 ;;
  145.   "-ignore_tagfiles")
  146.    ASK="never" ; shift 1 ;;
  147.   "-source_dir")
  148.    SOURCE_DIR=$2 ; shift 2 ;;
  149.   "-target_dir")
  150.    TARGET_DIR=$2
  151.    ADM_DIR=$TARGET_DIR/var/adm
  152.    shift 2 ;;
  153.   "-source_device")
  154.    SOURCE_DEVICE=$2 ; shift 2 ;;
  155.   esac
  156.  done
  157. else  # there were no arguments, so we'll get the needed information from the
  158.       # user and then go on.
  159.  CMD_START="true"
  160.  rm -f /tmp/SeT*
  161.  while [ 0 ]; do
  162.   dialog --title "Slackware Package Tool (pkgtool version 2.0.1)" \
  163. --menu "\nWelcome to the Slackware package tool.\n\
  164. \nWhich option would you like?\n" 17 74 6 \
  165. "Current" "Install packages from the current directory" \
  166. "Other" "Install packages from some other directory" \
  167. "Floppy" "Install packages from floppy disks" \
  168. "Remove" "Remove packages that are currently installed" \
  169. "View" "View the list of files contained in a package" \
  170. "Exit" "Exit Pkgtool" 2> /tmp/reply
  171.   if [ $? = 1 -o $? = 255 ]; then
  172.    rm -f /tmp/reply
  173.    reset
  174.    exit
  175.   fi
  176.   REPLY="`cat /tmp/reply`"
  177.   rm -f /tmp/reply
  178.   if [ "$REPLY" = "Exit" ]; then
  179.    reset
  180.    exit
  181.   fi
  182.   if [ "$REPLY" = "View" ]; then
  183.    dialog --title "SCANNING" --infobox "Please wait while \
  184. Pkgtool scans your system to determine which packages you have \
  185. installed and prepares a list for you. This will take \
  186. 1.`date +"%S"`E+`date +"%M"` BogoMipSeconds." 7 40
  187.    echo 'dialog --menu "Please select the package you wish to view." 15 55 8 \' > /tmp/viewscr
  188.    ls $ADM_DIR/packages | sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr
  189.    echo "2> /tmp/return" >> /tmp/viewscr
  190.    while [ 0 ]; do
  191.     source /tmp/viewscr
  192.     if [ ! "`cat /tmp/return`" = "" ]; then
  193.      dialog --title "CONTENTS OF PACKAGE: `cat /tmp/return`" --textbox "$ADM_DIR/packages/`cat /tmp/return`" \
  194.      22 74 2> /dev/null
  195.     else
  196.      break 
  197.     fi
  198.    done
  199.    rm -f /tmp/return /tmp/viewscr /tmp/tmpmsg
  200.    chmod 755 /
  201.    chmod 1777 /tmp
  202.    continue
  203.   fi  
  204.   if [ "$REPLY" = "Remove" ]; then
  205.    dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \
  206. your system to determine  which packages you have installed and prepares \
  207. a list for you. This will take 3.`date +"%S"`E+`date +"%M"` \
  208. BogoMipSeconds." 7 40
  209.    cat << EOF > $TMP/rmscript
  210. dialog --title "SELECT PACKAGES TO REMOVE" --checklist "Please select the \
  211. packages you wish to Remove. Use the \
  212. spacebar to select packages to delete, and the UP/DOWN arrow keys to \
  213. scroll up and down through the entire list." 22 75 13 \\
  214. EOF
  215.    for name in `ls $ADM_DIR/packages` ; do
  216.     BLURB="`sed -n \"/$name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -b10-60`"
  217.     echo " \"$name\" \"$BLURB\" off \\" >> $TMP/rmscript
  218.    done 
  219.    echo "2> /tmp/return" >> $TMP/rmscript
  220.    cat /dev/null > $LOG
  221.    chmod 700 $TMP/rmscript
  222.    export ADM_DIR;
  223.    $TMP/rmscript
  224.    remove_packages `cat /tmp/return | tr -d "\042"`
  225.    dialog --title "PACKAGE REMOVAL COMPLETE" --msgbox "The packages have been \
  226. removed. A complete log of the files that were removed has been created \
  227. in $TMP: PKGTOOL.REMOVED. Pkgtool does not remove empty directories, so you may \
  228. want to do that yourself." 8 63
  229.    rm -f $TMP/rmscript /tmp/return /tmp/tmpmsg /tmp/SeT*
  230.    chmod 755 /
  231.    chmod 1777 /tmp
  232.    dialog --clear
  233.    exit
  234.   elif [ "$REPLY" = "Floppy" ]; then
  235.    dialog --title "SELECT FLOPPY DRIVE" --menu "Which floppy drive would \
  236. you like to install from?" \
  237. 11 70 4 \
  238. "/dev/fd0H1440" "1.44 MB first floppy drive" \
  239. "/dev/fd1H1440" "1.44 MB second floppy drive" \
  240. "/dev/fd0h1200" "1.2 MB first floppy drive" \
  241. "/dev/fd1h1200" "1.2 MB second floppy drive" 2> /tmp/wdrive
  242.    if [ $? = 1 ]; then
  243.     dialog --clear
  244.     exit
  245.    fi
  246.    SOURCE_DEVICE="`cat /tmp/wdrive`"
  247.    rm -f /tmp/wdrive 
  248.    cat << EOF > /tmp/tmpmsg
  249.  
  250. Enter the names of any disk sets you would like to install.
  251. Seperate the sets with a space, like this: a b oi x
  252.  
  253. To install packages from one disk, hit [enter] without typing
  254. anything.
  255.  
  256. EOF
  257.    dialog --title "SOFTWARE SELECTION" --inputbox "`cat /tmp/tmpmsg`" 13 70 2> /tmp/sets 
  258.    DISK_SETS="`cat /tmp/sets`"
  259.    rm -f /tmp/sets
  260.    if [ "$DISK_SETS" = "" ]; then
  261.     DISK_SETS="disk"
  262.    else
  263.     DISK_SETS=`echo $DISK_SETS | sed 's/ /#/g'`
  264.     DISK_SETS="#$DISK_SETS"
  265.    fi
  266.    break;
  267.   elif [ "$REPLY" = "Other" ]; then
  268.    dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the name of the directory that you wish to \
  269. install packages from:" 10 50 2> /tmp/pkgdir
  270.    if [ $? = 1 ]; then
  271.     rm -f /tmp/pkgdir /tmp/SeT*
  272.     reset
  273.     exit
  274.    fi 
  275.    SOURCE_DIR="`cat /tmp/pkgdir`"
  276.    SOURCE_MOUNTED="always"
  277.    DISK_SETS="disk" 
  278.    chmod 755 $TARGET_DIR
  279.    chmod 1777 $TARGET_DIR/tmp
  280.    rm -f /tmp/pkgdir
  281.    if [ ! -d $SOURCE_DIR ]; then
  282.     dialog --title "DIRECTORY NOT FOUND" --msgbox "The directory you want to \
  283. install from ($SOURCE_DIR) \
  284. does not seem to exist. Please check the directory and then try again." \
  285. 10 50
  286.     reset
  287.     exit
  288.    fi
  289.    break;
  290.   else # installing from current directory
  291.    SOURCE_MOUNTED="always"
  292.    SOURCE_DIR="$PWD"
  293.    DISK_SETS="disk" 
  294.    chmod 755 $TARGET_DIR
  295.    chmod 1777 $TARGET_DIR/tmp
  296.    break;
  297.   fi 
  298.  done
  299. fi
  300. if [ "$DISK_SETS" = "disk" ]; then
  301.  ASK="always"
  302. fi
  303.  
  304. for DIR in $ADM_DIR $ADM_DIR/packages $ADM_DIR/scripts $ADM_DIR/disk_contents
  305. do
  306.  if [ ! -d $DIR ]; then mkdir -p $DIR ; chmod 755 $DIR ; fi
  307. done
  308.  
  309. if [ ! -d $ADM_DIR/mount -a ! -L $ADM_DIR/mount ]; then
  310.  mkdir -p $ADM_DIR/mount ; chmod 755 $ADM_DIR/mount
  311. fi
  312.  
  313. mount_the_source() {
  314.  # is the source supposed to be mounted already?
  315.  if [ "$SOURCE_MOUNTED" = "always" ]; then
  316.   # The source should already be mounted, so we test it
  317.   if [ ! -d $SOURCE_DIR ]; then # the directory is missing
  318.    cat << EOF > /tmp/tmpmsg
  319.  
  320. Your source device cannot be accessed properly.
  321.  
  322. Please be sure that it is mounted on /var/adm/mount,
  323. and that the Slackware disks are found in subdirectories 
  324. of $SOURCE_DIR like specified.
  325.  
  326. EOF
  327.    dialog --title "MOUNT ERROR" --msgbox "`cat /tmp/tmpmsg`" 11 67
  328.    rm -f /tmp/tmpmsg
  329.    exit 1;
  330.   fi
  331.   return 0;
  332.  fi
  333.  dialog --title "INSERT DISK" --menu "Please insert disk $1 and \
  334. press ENTER to continue." \
  335. 11 50 3 \
  336. "Continue" "Continue with the installation" \
  337. "Skip" "Skip the current disk series" \
  338. "Quit" "Abort the installation process" 2> /tmp/reply
  339.  if [ $? = 1 -o $? = 255 ]; then
  340.   REPLY="Quit"
  341.  else
  342.   REPLY="`cat /tmp/reply`"
  343.  fi
  344.  rm -f /tmp/reply
  345.  if [ "$REPLY" = "Skip" ]; then
  346.   return 1;
  347.  fi
  348.  if [ "$REPLY" = "Quit" ]; then
  349.    dialog --title "ABORTING" --msgbox "Aborting software installation." 5 50
  350.    chmod 755 $TARGET_DIR
  351.    chmod 1777 $TARGET_DIR/tmp
  352.    exit 1;
  353.  fi;
  354.  # Old line:
  355.  # mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  356.  # New ones: (thanks to Andy Schwierskott!)
  357.  go_on=y
  358.  not_successfull_mounted=1
  359.  while [ "$go_on" = y -a "$not_successfull_mounted" = 1 ]; do
  360.   mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  361.   not_successfull_mounted=$?
  362.   if [ "$not_successfull_mounted" = 1 ]; then
  363.    mount_answer=x
  364.    while [ "$mount_answer" != "y" -a "$mount_answer" != "q" ] ; do
  365.     dialog --title "MOUNT PROBLEM" --menu "Media was not successfully \
  366. mounted! Do you want to \
  367. retry, or quit?" 10 60 2 \
  368. "Yes" "Try to mount the disk again" \
  369. "No" "No, abort." 2> /tmp/mntans
  370.     mount_answer="`cat /tmp/mntans`"
  371.     rm -f /tmp/mntans
  372.     if [ "$mount_answer" = "Yes" ]; then
  373.      mount_answer="y"
  374.     else
  375.      mount_answer="q"
  376.     fi
  377.    done
  378.    go_on=$mount_answer
  379.   fi
  380.  done
  381.  test $not_successfull_mounted = 0
  382. }
  383. umount_the_source() {
  384.  if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  385.   umount $SOURCE_DEVICE 1> /dev/null 2>&1
  386.  fi;
  387. }
  388. # The function below installs the package with the name $CURRENT_PACKAGE_NAME
  389. # and with the DOS file extension .tgz
  390. install_the_current_package() {
  391.  rm -f $ADM_DIR/removed_packages/$CURRENT_PACKAGE_NAME
  392.  rm -f $ADM_DIR/removed_scripts/$CURRENT_PACKAGE_NAME
  393.  echo "PACKAGE NAME:     $CURRENT_PACKAGE_NAME" > $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  394.  KSIZE=`expr $PACKAGE_SIZE / 1024`
  395.  echo "PACKAGE SIZE:     $KSIZE K" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  396.  BASE_DISK_NAME=`basename $PACKAGE_DIR/disk*`
  397.  echo "PACKAGE LOCATION: $BASE_DISK_NAME" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  398.  echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  399.  if [ -r $PACKAGE_DIR/$BASE_DISK_NAME -a ! -d $PACKAGE_DIR/$BASE_DISK_NAME ]; then
  400.   fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$BASE_DISK_NAME | uniq >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  401.  fi
  402.  echo "FILE LIST:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  403.  # Pat's new-new pre-install cleanup routine.
  404.  if [ -r $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME -a ! -d $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME ]; then
  405.   cat $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME | fgrep 'rm -rf' | sort -u > $TMP/del_link_list
  406.   if [ ! -d $ADM_DIR/removed_scripts ]; then
  407.    mkdir $ADM_DIR/removed_scripts
  408.   fi
  409.   mv $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME $ADM_DIR/removed_scripts 1> /dev/null 2>&1
  410.   cat $ADM_DIR/scripts/* | fgrep 'rm -rf' | sort -u > $TMP/required_links
  411.   comm -12 $TMP/del_link_list $TMP/required_links | keep_links
  412.   comm -23 $TMP/del_link_list $TMP/required_links | delete_links
  413.   comm -23 $TMP/del_link_list $TMP/required_links > $TMP/delscript
  414.   ( cd $TARGET_DIR ; sh $TMP/delscript )
  415.   rm -f $TMP/del_link_list $TMP/required_links $TMP/delscript $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  416.  fi
  417.  # Install the package:
  418.  (cd $TARGET_DIR; tar -xzlpvf - ) < $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME 2> /dev/null
  419.  chmod 644 $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  420.  if [ -f $TARGET_DIR/install/doinst.sh ]; then
  421.   # Executing installation script for package $CURRENT_PACKAGE_NAME... 
  422.   (cd $TARGET_DIR; sh $TARGET_DIR/install/doinst.sh -install; )
  423.   cp $TARGET_DIR/install/doinst.sh $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  424.   chmod 755 $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  425.   # Clean up the mess...
  426.   if [ -d $TARGET_DIR/install ]; then
  427.    (cd $TARGET_DIR/install ; rm -r -f doin* 1> /dev/null 2>&1 )
  428.    rmdir $TARGET_DIR/install 1> /dev/null 2>&1
  429.   fi
  430.  fi
  431.  # Now we reload the shell hash table in case we've added something useful
  432.  # to the command path:
  433.  hash -r
  434.  # Done installing package $CURRENT_PACKAGE_NAME.
  435. }
  436. install_disk() {
  437.  mount_the_source $1
  438.  if [ $? = 1 ]; then
  439.   umount_the_source;
  440.   return 1;
  441.  fi
  442.  CURRENT_DISK_NAME="$1"
  443.  PACKAGE_DIR=$SOURCE_DIR
  444.  if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then
  445.    PACKAGE_DIR=$PACKAGE_DIR/$1
  446.  fi
  447.  touch $TMP/tagfile
  448.  if [ ! "$DISK_SETS" = "disk" ]; then
  449.   if [ -r /tmp/SeTtagext ]; then
  450.    if [ -r $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` ]; then
  451.     cat $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` >> $TMP/tagfile
  452.    else
  453.     if [ -r $PACKAGE_DIR/tagfile ]; then
  454.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  455.     fi
  456.    fi
  457.   elif [ -r /tmp/SeTtagpath ]; then
  458.    custom_path=`cat /tmp/SeTtagpath`
  459.    short_path=`basename $PACKAGE_DIR`
  460.    if [ -r $custom_path/$short_path/tagfile ]; then
  461.     cat $custom_path/$short_path/tagfile >> $TMP/tagfile
  462.    else
  463.     if [ -r $PACKAGE_DIR/tagfile ]; then
  464.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  465.     fi
  466.    fi
  467.   elif [ -r $PACKAGE_DIR/tagfile ]; then
  468.    cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  469.   fi
  470. #
  471. # Execute menus if in QUICK mode:
  472. #
  473.   if [ -r /tmp/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then
  474.    sh $PACKAGE_DIR/maketag
  475.    if [ -r /tmp/SeTnewtag ]; then
  476.     mv /tmp/SeTnewtag $TMP/tagfile
  477.    fi
  478.   fi
  479.   if [ -r $TMP/tagfile ]; then
  480.    chmod 600 $TMP/tagfile
  481.   fi
  482.  fi
  483.  if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 ]; then
  484.   CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  485.   if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  486.    if fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then
  487.     # First we check for missing packages...
  488.     for PKGTEST in `fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null` ; do
  489.      if [ ! -r $PACKAGE_DIR/$PKGTEST.tgz ]; then
  490.       cat << EOF > /tmp/tmpmsg
  491.  
  492. WARNING!!!
  493.  
  494. While looking through your index file ($CATALOG_FILE), I 
  495. noticed that you might be missing a package ($PKGTEST.tgz) 
  496. that is supposed to be on this disk (disk $1). You may go
  497. on with the installation if you wish, but if this is a 
  498. crucial file I'm making no promises that your machine will
  499. boot.
  500.  
  501. EOF
  502.       dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \
  503. "`cat /tmp/tmpmsg`" 15 73
  504.      fi
  505.     done # checking for missing packages
  506.     # Now we test for extra packages
  507.     ALLOWED="`fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null`" 
  508.     for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  509.      BASE="`basename $PACKAGE_FILENAME .tgz`"
  510.      if echo $ALLOWED | fgrep $BASE 1> /dev/null 2>&1 ; then
  511.       GOOD="yup yup"
  512.      else
  513.       cat << EOF > /tmp/tmpmsg
  514.  
  515. WARNING!!!
  516.  
  517. While looking through your index file ($CATALOG_FILE), I 
  518. noticed that you have this extra package ($BASE.tgz) that
  519. I don't recongnize. Please be sure this package is really
  520. supposed to be here, and is not left over from an old 
  521. version of Slackware. Sometimes this can happen at the 
  522. archive sites.
  523.  
  524. EOF
  525.       dialog --title "EXTRA FILE FOUND ON YOUR DISK" \
  526. --msgbox "`cat /tmp/tmpmsg`" 15 67 
  527.       rm -f /tmp/tmpmsg
  528.      fi
  529.     done 
  530.    fi
  531.    cat $PACKAGE_DIR/$CATALOG_FILE > $ADM_DIR/disk_contents/$CATALOG_FILE
  532.    chmod 644 $ADM_DIR/disk_contents/$CATALOG_FILE
  533.   fi
  534.   for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  535.    if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.tgz" ]; then
  536.     continue;
  537.    fi
  538.    CURRENT_PACKAGE_NAME=`basename $PACKAGE_FILENAME .tgz`
  539.    AddKey=""
  540.    SkipKey=""
  541.    if [ "$ASK" = "tagfiles" ]; then # -a ! "$DISK_SETS" = "disk" ]; then
  542.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD 1> /dev/null 2>&1 ; then
  543.      AddKey="ADD"
  544.     fi
  545.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP 1> /dev/null 2>&1 ; then
  546.      SkipKey="SKIP"
  547.     fi
  548.    elif [ "$ASK" = "never" ]; then
  549.     AddKey="ADD"
  550.    else # ASK must equal always
  551.     ASK="always"
  552.     fi  
  553.    if [ ! "$DISK_SETS" = "disk" ]; then
  554.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD > /dev/null 2> /dev/null ; then
  555.      PRIORITY="[required]"
  556.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep REC > /dev/null 2> /dev/null ; then
  557.      PRIORITY="[recommended]"
  558.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep OPT > /dev/null 2> /dev/null ; then
  559.      PRIORITY="[optional]"
  560.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP > /dev/null 2> /dev/null ; then
  561.      PRIORITY="[skip]"
  562.     else
  563.      PRIORITY="[unknown]"
  564.     fi
  565.    fi
  566.    PACKAGE_SIZE=`filesize $PACKAGE_FILENAME`
  567.    if [ "$AddKey" = "ADD" ]; then
  568.     # echo "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  569.     echo > /tmp/tmpmsg
  570.     # Print out the description text:
  571.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  572.     if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  573.      fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  574.     fi
  575.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  576.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  577.     COMPRESSED="`expr $COMPBYTES / 1024`K"
  578.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024`K"
  579.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  580.     if [ ! "$PRIORITY" = "" ]; then
  581.      PMSG="  Priority: $PRIORITY"
  582.     else
  583.      PMSG=""
  584.     fi
  585.     dialog --title "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==$PMSG" --infobox "`cat /tmp/tmpmsg`" 15 75
  586.     rm -f /tmp/tmpmsg
  587.     install_the_current_package;
  588.    elif [ "$SkipKey" != "SKIP" ]; then
  589.     # echo "Package Name: ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  590.     echo > /tmp/tmpmsg
  591.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  592.     if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  593.      fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  594.     fi
  595.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  596.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  597.     COMPRESSED="`expr $COMPBYTES / 1024`K"
  598.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024`K"
  599.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  600.     echo >> /tmp/tmpmsg
  601.     echo "Install package $CURRENT_PACKAGE_NAME? " >> /tmp/tmpmsg
  602.     if [ ! "$PRIORITY" = "" ]; then
  603.      PMSG="  Priority: $PRIORITY"
  604.     else
  605.      PMSG=""
  606.     fi
  607.     dialog --title "Package Name: ==>$CURRENT_PACKAGE_NAME<==$PMSG" --menu "`cat /tmp/tmpmsg`" 22 75 1 \
  608. "Yes" "Install package $CURRENT_PACKAGE_NAME" \
  609. "No" "Do not install package $CURRENT_PACKAGE_NAME" \
  610. "Quit" "Abort software installation completely" 2> /tmp/reply
  611.     if [ $? = 1 -o $? = 255 ]; then
  612.      echo "No  " > /tmp/reply
  613.     fi
  614.     REPLY="`cat /tmp/reply`"
  615.     rm -f /tmp/reply /tmp/tmpmsg
  616.     if [ "$REPLY" = "Yes" ]; then
  617.      dialog --title "INSTALLING" --infobox "Installing package $CURRENT_PACKAGE_NAME" 3 50
  618.      install_the_current_package;
  619.     elif [ "$REPLY" = "Quit" ]; then
  620.      umount_the_source;
  621.      chmod 755 $TARGET_DIR
  622.      chmod 1777 $TARGET_DIR/tmp
  623.      exit 1;
  624.     elif [ "$REPLY" = "No" ]; then
  625.      dialog --title "SKIPPING PACKAGE" --infobox "Skipping package $CURRENT_PACKAGE_NAME" 3 50
  626.     fi
  627.    fi
  628.   done
  629.   OUTTAHERE="false"
  630.   if [ -r $PACKAGE_DIR/install.end ]; then
  631.    OUTTAHERE="true"
  632.   fi
  633.   umount_the_source;
  634.   if [ "$OUTTAHERE" = "true" ]; then
  635.    return 1;
  636.   fi
  637.  else
  638.   umount_the_source;
  639.   if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  640.    cat << EOF > /tmp/tmpmsg
  641.  
  642. This does not look like the correct disk. You may either check to
  643. see if you've got the right disk in there ($1) and try again, or 
  644. you may skip the current disk series.
  645.  
  646. EOF
  647.    dialog --title "INCORRECT DISK INSERTED" --menu "`cat /tmp/tmpmsg`" 15 70 2 \
  648. "Retry" "Try to mount disk $1 again" \
  649. "Skip" "Skip this disk series" 2> /tmp/reply
  650.    if [ $? = 1 -o $? = 255 ]; then
  651.     rm -f /tmp/reply /tmp/tmpmsg
  652.     exit
  653.    fi
  654.    REPLY="`cat /tmp/reply`"
  655.    rm -f /tmp/reply /tmp/tmpmsg
  656.    if [ "$REPLY" = "Skip" ]; then
  657.     return 1;
  658.    else
  659.     install_disk $1;
  660.    fi
  661.   else
  662.    cat << EOF > /tmp/tmpmsg
  663. WARNING:
  664.  
  665. Can't find a disk series $SERIES_NAME in the source directory.
  666. Skipping it...
  667.  
  668. EOF
  669.    dialog --title "SELECTED SERIES NOT PRESENT" --msgbox "`cat /tmp/tmpmsg`" 10 65
  670.    rm -f /tmp/tmpmsg
  671.    return 1; 
  672.   fi 
  673.  fi;
  674. }
  675. install_disk_set() { # accepts one argument: the series name in lowercase.
  676.  SERIES_NAME=$1
  677.  CURRENT_DISK_NUMBER="1";
  678.  while [ 0 ]; do
  679.   install_disk $SERIES_NAME$CURRENT_DISK_NUMBER;
  680.   if [ $? = 1 -o $? = 255 ]; then # install.end was found, or the user chose
  681.         # to quit installing packages.
  682.    return 0;
  683.   fi
  684.   CURRENT_DISK_NUMBER=`expr $CURRENT_DISK_NUMBER + 1`
  685.  done;
  686. }
  687. if [ "$DISK_SETS" = "disk" ]; then
  688.  install_disk single_disk;
  689.  ASK="always"
  690. else
  691.  touch $TMP/tagfile
  692.  chmod 600 $TMP/tagfile
  693.  if echo $DISK_SETS | fgrep "#a#" 1> /dev/null 2>&1; then
  694.   A_IS_NEEDED="true"
  695.  else
  696.   A_IS_NEEDED="false"
  697.  fi
  698.  while [ 0 ];
  699.  do
  700.   while [ 0 ]; # strip leading '#'s
  701.   do
  702.    if [ "`echo $DISK_SETS | cut -b1`" = "#" ]; then
  703.     DISK_SETS="`echo $DISK_SETS | cut -b2-`"
  704.    else
  705.     break;
  706.    fi
  707.   done
  708.   if [ "$A_IS_NEEDED" = "true" ]; then
  709.    if [ "$TARGET_DIR" = "/" ]; then
  710.     dialog --title "WARNING: BIG TROUBLE DETECTED" \
  711. --menu " *** WARNING!  Reinstalling your A series to a running system \
  712. is not (yet) a good idea. It is suggested that you do not do this." \
  713. 11 70 3 \
  714. "Abort" "Abort software installation." \
  715. "Ignore" "Ignore warning and reinstall the A series anyway." \
  716. "Skip" "Skip the A series, but continue installing software." 2> /tmp/skip
  717.     if [ $? = 1 -o $? = 255 ]; then
  718.      exit
  719.     fi
  720.     WHATDO="`cat /tmp/skip`" 
  721.     rm -f /tmp/skip
  722.     if [ "$WHATDO" = "Abort" ]; then
  723.      dialog --msgbox "Aborting..." 5 30
  724.      A_IS_NEEDED="false"
  725.      DISK_SETS=""
  726.      continue;
  727.     elif [ "$WHATDO" = "Skip" ]; then
  728.      dialog --msgbox "Skipping A series..." 5 30
  729.      A_IS_NEEDED="false"
  730.      continue;
  731.     elif [ ! "$WHATDO" = "Ignore" ]; then
  732.      continue; # unknown response
  733.     fi
  734.    fi
  735.    cat << EOF > /tmp/tmpmsg
  736.  
  737. --- Installing disk series ==>a<==
  738.  
  739. EOF
  740.    dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  741.    sleep 1
  742.    rm -f /tmp/tmpmsg
  743.    install_disk_set a;
  744.    A_IS_NEEDED="false"
  745.   fi
  746.   count="1"
  747.   if [ "`echo $DISK_SETS | cut -b$count`" = "" ]; then
  748.    break; # we be done here :^)
  749.   else
  750.    count="2"
  751.    while [ 0 ]; do
  752.     if [ "`echo $DISK_SETS | cut -b$count`" = "" -o "`echo $DISK_SETS | cut -b$count`" = "#" ]; then
  753.      count="`expr $count - 1`"
  754.      break;
  755.     else
  756.      count="`expr $count + 1`"
  757.     fi 
  758.    done
  759.   fi 
  760.   diskset="`echo $DISK_SETS | cut -b1-$count`"
  761.   count="`expr $count + 1`"
  762.   DISK_SETS="`echo $DISK_SETS | cut -b$count-`"
  763.   if [ "$diskset" = "a" ]; then
  764.    continue; # we expect this to be done elsewhere
  765.   fi
  766.   cat << EOF > /tmp/tmpmsg
  767.  
  768. Installing disk series ==>$diskset<==
  769.  
  770. EOF
  771.   dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  772.   sleep 1
  773.   rm -f /tmp/tmpmsg
  774.   install_disk_set $diskset; 
  775.  done
  776. fi
  777.  
  778. if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then
  779.  if [ -r $TMP/tagfile ]; then
  780.   rm $TMP/tagfile
  781.  fi
  782.  reset
  783. fi
  784. chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr
  785. chmod 1777 $TARGET_DIR/tmp
  786.